<html>
<head><meta charset="utf-8"><title>Auto-imports and coc.nvim · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports.20and.20coc.2Envim.html">Auto-imports and coc.nvim</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="198276900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports%20and%20coc.nvim/near/198276900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Marcus Buffett <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports.20and.20coc.2Envim.html#198276900">(May 21 2020 at 01:21)</a>:</h4>
<p>Just trying to use rust-analyzer in vim, specifically for the auto-importing functionality. It seems like according to the assists documentation, if I have an unresolved name, then I should be able to get a prompt from rust-analyzer to add an import. So I type something like <code>let x = Transform::new()</code>, then bring up the language server actions, but I only see "Extract into variable" and "Implement default members", when I would hope to get a suggestion to import from <code>amethyst::core::Transform</code>. Any help would be much appreciated! Also hopefully creating a topic is the way to go for this, first time zulip-er</p>



<a name="198286298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports%20and%20coc.nvim/near/198286298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports.20and.20coc.2Envim.html#198286298">(May 21 2020 at 04:46)</a>:</h4>
<p>Can you try in an empty project, just to make sure it's not related to Amethyst? Importing something like <code>HashMap</code> should work fine.</p>



<a name="198318290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports%20and%20coc.nvim/near/198318290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports.20and.20coc.2Envim.html#198318290">(May 21 2020 at 13:09)</a>:</h4>
<p>I was unable to get this to work (none of the import-related functionality works for me) in vim and coc.nvim. I haven't had the time to investigate...</p>



<a name="198318496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports%20and%20coc.nvim/near/198318496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports.20and.20coc.2Envim.html#198318496">(May 21 2020 at 13:11)</a>:</h4>
<p>I only tested it in LanguageClient-neovim</p>



<a name="198526314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports%20and%20coc.nvim/near/198526314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Timo Freiberg <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports.20and.20coc.2Envim.html#198526314">(May 23 2020 at 09:04)</a>:</h4>
<p>Autoimport works when using coc.nvim and coc-rust-analyzer, but the default behaviour of <code>coc-codeaction</code> was changed recently to apply to the whole buffer, and rust-analyzer only offers assists if the selection is specific enough.<br>
See <a href="https://github.com/fannheyward/coc-rust-analyzer/pull/252#issuecomment-632427338">https://github.com/fannheyward/coc-rust-analyzer/pull/252#issuecomment-632427338</a> and <a href="https://github.com/neoclide/coc.nvim/issues/1981">https://github.com/neoclide/coc.nvim/issues/1981</a><br>
If you have a binding to <code>&lt;Plug&gt;(coc-codeaction)</code>, you probably want to change it to call <code>v&lt;Plug&gt;(coc-codeaction-selected)</code> for now</p>



<a name="198531832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports%20and%20coc.nvim/near/198531832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Auto-imports.20and.20coc.2Envim.html#198531832">(May 23 2020 at 11:52)</a>:</h4>
<p>will try that, thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>